import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class WindowExit extends JFrame {
   WindowExit() {
      setBounds(100,100,200,300);
      setVisible(true);
      addWindowListener(new WindowAdapter() {
                          public void windowActivated(WindowEvent e) {
                             setTitle("我被激活");
                          }
                          public void windowClosing(WindowEvent e) {
                             System.exit(0);
                          }
                       });
   }
}
